/*
 * @Description: 
 * @Author: zoe
 * @Date: 2024-09-29 10:30:41
 * @LastEditors: rendc
 * @LastEditTime: 2024-09-29 10:35:42
 */

import java.util.LinkedList;

public class Test04LinkedList {
    public static void main(String[] args) {
        //操作集合的次数
        final int NUM = 100000;
        //实例化集合对象
        LinkedList<String> list = new LinkedList<String>();
        //往集合中存放对象
        //开始计时
        long start = System.currentTimeMillis();
        for(int i = 0; i < NUM; i++){
            list.add(0,"hello" + i);
        }
        //结束计时
        long end = System.currentTimeMillis();
        //计算时间
        System.out.println("插入" + NUM +"条数据用时" + (end - start) + "毫秒");
        //开始计时
        long start1 = System.currentTimeMillis();
        for(int i = 0; i < NUM; i++){
            list.get(1);
        }
        //结束计时
        long end1 = System.currentTimeMillis();
        //计算时间
        System.out.println("查询" + NUM +"条数据用时" + (end1 - start1) + "毫秒");
    }
}